//
//  SigningInViewController.m
//  HelloWorld
//
//  Created by Martin Le C. on 6/3/09.
//  Copyright 2009 __MyCompanyName__. All rights reserved.
//

#import "SigningInViewController.h"
#import "Session.h"
#import "HelloWorldAppDelegate.h"
@implementation SigningInViewController
@synthesize signingNotice;
@synthesize cancelButton;
@synthesize userImage;
@synthesize yahooID;
/*
// The designated initializer. Override to perform setup that is required before the view is loaded.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
        // Custom initialization
    }
    return self;
}
*/

/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
	self.navigationItem.hidesBackButton = YES;
	self.navigationItem.title = @"Signing In";
	[cancelButton addTarget:self action:@selector(cancelSignIn) forControlEvents:UIControlEventTouchDown];

	//[self viewConnectingAnimation];
}
- (void)viewDidAppear:(BOOL)animated  {
	signingNotice.text = [NSString stringWithFormat:@"Signing in as %@", yahooID];
	[self viewAvatar];
		
}
- (void)viewAvatar{
	NSString* mapURL = [[NSString stringWithFormat:@"http://img.msg.yahoo.com/avatar.php?yids=%@&format=png",yahooID] stringByReplacingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
	NSData* imageData = [[NSData alloc]initWithContentsOfURL:[NSURL URLWithString:mapURL]];
	UIImage* image = [[UIImage alloc] initWithData:imageData];
	[userImage setImage:image];
	[imageData release];
	[image release];
} 
/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/
- (void)didReceiveMemoryWarning {
	NSLog(@"fucking iphone");
    [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
    // Release anything that's not essential, such as cached data
}
- (void)cancelSignIn {
	HelloWorldAppDelegate *appDelegate = [UIApplication sharedApplication].delegate;
	[appDelegate cancelSignIn];
}

- (void)dealloc {
	[userImage release];
	[signingNotice release];
	[cancelButton release];
    [super dealloc];
}


@end
